<?php
class InputAttr extends BaseAttr{
	public function InputAttr($attr, $lang=null, $mutil_lang=false){
		parent::BaseAttr($attr, $lang, $mutil_lang);
	}
	
	public function get_post_val(&$getted_post_data){
		$trait = $this->attr['trait'];
		if($trait === 'mutil'){
			return $this->get_mutil_vals($getted_post_data);
		}else{
			return parent::get_post_val($getted_post_data);
		}
	}
	
	private function get_mutil_vals(&$getted_post_data){
		$name = $this->attr['id'];
		$require = $this->attr['required'];
		if($this->mutil_lang!==false){
			$data = array();
			foreach ($this->formHelper->langs as $lang){
				if(!isset($_POST[$lang . '_' . $name])) return false;
				$temp_data = $_POST[$lang . '_' . $name];
				$data[$lang] = $this->clean_data($temp_data);
				$getted_post_data[$lang][$name] = $temp_data;
			}
		}else{
			if(!isset($_POST[$name])) return false;
			$data = $this->clean_data($_POST[$name]);
			$getted_post_data[$name] = $data;
		}
		return $data;
		
	}
	
	private function clean_data($vs){
		$result = array();
		foreach ($vs as $v){
			if(!empty($v) && !in_array($v, $result)){
				$result[] = $v;
			}
		}
		return $result;
	}
}

?>